package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * 项目、供货订单结算状态
 * @author chenyejian
 * @date 2024-07-21
 */
@Getter
public enum SettlementStatus {
    /**
     * 未结算
     */
    UNSETTLED("0", "未结算"),
    /**
     * 对账中
     */
    SETTLEMENT_ING("1", "结算中"),
    /**
     * 已对账
     */
    SETTLED("2", "已结算"),
    /**
     * 部分对账
     */
    PARTIALLY_SETTLED("3", "部分结算"),
    /**
     * 云采已确认
     */
    YUNCAI_CONFIRMED("4", "云采已确认");

    private final String type;
    private final String description;

    SettlementStatus(String type, String description) {
        this.type = type;
        this.description = description;
    }
    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(String type) {
        for (SettlementStatus status : SettlementStatus.values()) {
            if (status.getType().equalsIgnoreCase(type)) {
                return status.getDescription();
            }
        }
        return type;
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static String getTypeByDesc(String description) {
        for (SettlementStatus status : SettlementStatus.values()) {
            if (status.getDescription().equalsIgnoreCase(description)) {
                return status.getType();
            }
        }
        return description;
    }
}
